{% extends 'base.html' %}
{% load staticfiles %}
{% load crispy_forms_tags %}
{% load martortags %}

{% block csslink %}
    <link href="{% static 'plugins/css/ace.min.css' %}" type="text/css" media="all" rel="stylesheet"/>
    <link href="{% static 'plugins/css/semantic.min.css' %}" type="text/css" media="all" rel="stylesheet"/>
    <link href="{% static 'plugins/css/resizable.min.css' %}" type="text/css" media="all" rel="stylesheet"/>
    <link href="{% static 'martor/css/martor.min.css' %}" type="text/css" media="all" rel="stylesheet"/>
{% endblock %}

{% block style %}

{% endblock %}

{% block content %}
    <div class="row mb-4">
        <div class="col-md-4">
            {% if create_or_update == 1 %}
                <h2 class="t2">添加机房日志</h2>
            {% elif create_or_update == 2 %}
                <h2 class="t2">修改机房日志</h2>
            {% endif %}
        </div>

        <div class="col-md-4 mt-3">
            <div class="font-weight-light">
                日志日期：{{ log_date | date:'Y年m月d日' }}<span id="week" class="m-1"></span>
                {% if time_slot == 1 %} 上午 {% else %} 下午 {% endif %}
            </div>
        </div>

        <div class="col-md-1 offset-md-1 mt-3">
            <div class="font-weight-bold">值班人：</div>
        </div>
        <div class="col-md-2 mt-2">
            <select name="" id="" class="select form-control">
                <option value="name">李孝宾</option>
                <option value="name">茶文剑</option>
            </select>
        </div>
    </div>
    <form method="post">
        {% csrf_token %}
        <div class="form-row">
            <div class="form-group col-md-6 mb-0">
                {{ form.weather|as_crispy_field }}
            </div>
            <div class="form-group col-md-6 mb-0">
                {{ form.log_time|as_crispy_field }}
            </div>
        </div>
        <div class="form-row">
            <div class="form-group col-md-6 mb-0">
                {{ form.lab_template|as_crispy_field }}
            </div>
            <div class="form-group col-md-6 mb-0">
                {{ form.lab_humidity|as_crispy_field }}
            </div>
        </div>
        <div class="form-row">
            <div class="form-group col-md-6 mb-0">
                {{ form.hc_room_template|as_crispy_field }}
            </div>
            <div class="form-group col-md-6 mb-0">
                {{ form.hc_room_humidity|as_crispy_field }}
            </div>
        </div>
        <div class="form-row">
            <div class="form-group col-md-6 mb-0">
                {{ form.network_delay|as_crispy_field }}
            </div>
            <div class="form-group col-md-6 mb-0">
                {{ form.packet_lose_rate|as_crispy_field }}
            </div>
        </div>

        <div class="form-row">
            <div class="col-md-12 mb-0">
                {{ form.description }}
            </div>
        </div>
        {% if create_or_update == 1 %}
            <button type="submit" class="btn btn-primary">添加</button>
        {% elif create_or_update == 2 %}
            <button type="submit" class="btn btn-primary">修改</button>
        {% endif %}
    </form>

    {#    {% crispy form %}#}
    <!--
    <form method="post" novalidate>
{#        {% csrf_token %}#}
{#        {{ form|crispy }}#}
{#        {% if create_or_update == 1 %}#}
            <button type="submit" class="btn btn-primary">提交</button>
{#        {% elif create_or_update == 2 %}#}
            <button type="submit" class="btn btn-primary">修改</button>
{#        {% endif %}#}

    </form>
    -->
{% endblock content %}

{% block script %}
    <script type="text/javascript" src="{% static 'plugins/js/ace.js' %}"></script>
    <script type="text/javascript" src="{% static 'plugins/js/semantic.min.js' %}"></script>
    <script type="text/javascript" src="{% static 'plugins/js/mode-markdown.js' %}"></script>
    <script type="text/javascript" src="{% static 'plugins/js/ext-language_tools.js' %}"></script>
    <script type="text/javascript" src="{% static 'plugins/js/theme-github.js' %}"></script>
    <script type="text/javascript" src="{% static 'plugins/js/highlight.min.js' %}"></script>
    <script type="text/javascript" src="{% static 'plugins/js/resizable.min.js' %}"></script>
    <script type="text/javascript" src="{% static 'plugins/js/emojis.min.js' %}"></script>
    <script type="text/javascript" src="{% static 'martor/js/martor.min.js' %}"></script>
    <script type="text/javascript">
        $(document).ready(function () {
            var int_week = {{ date | date:'w' }};
            var str_week = '星期';
            switch (int_week) {
                case 0:
                    str_week += '日';
                    break;
                case 1:
                    str_week += '一';
                    break;
                case 2:
                    str_week += '二';
                    break;
                case 3:
                    str_week += '三';
                    break;
                case 4:
                    str_week += '四';
                    break;
                case 5:
                    str_week += '五';
                    break;
                case 6:
                    str_week += '六';
                    break;
                default:
                    str_week += ''
            }
            $('#week').html(str_week)
        });
    </script>


{% endblock script %}